home *** CD-ROM | disk | FTP | other *** search
- import java.awt.Color;
- import java.awt.Graphics;
- import java.awt.Rectangle;
- import java.io.DataInputStream;
-
- public class CTextAction extends CDisplayAction {
- protected String m_strText;
- protected Color m_rgbText;
- protected Color m_rgbBackground;
- protected Color m_rgbShadow;
- protected byte m_cShadowOffsetX;
- protected byte m_cShadowOffsetY;
- protected int m_nFlags;
- protected CFontObject m_Font;
- protected CVarOrValue m_vvAngle;
- private String m_strPaintText;
-
- boolean DoAction() {
- boolean var1 = false;
- if (this.m_Font.isUnderlined()) {
- this.m_nFlags |= 8192;
- }
-
- if (this.m_Font.isStruckOut()) {
- this.m_nFlags |= 32768;
- }
-
- if (this.m_strText.length() > 0) {
- String var2 = Utils.InsertVariablesInString(this.m_strText);
- if (!this.m_strPaintText.equals(var2)) {
- this.m_strPaintText = var2;
- var1 = true;
- }
-
- CRect var3;
- if ((this.m_nFlags & 16) != 0) {
- var3 = new CRect(((CDisplayAction)this).GetActualRect());
- } else {
- Graphics var4 = Globals.thePresView.GetDC();
- var4.setFont(this.m_Font.GetFont());
- var3 = new CRect(Utils.DrawText(var4, this.m_strPaintText, ((CDisplayAction)this).GetActualRect(), this.m_nFlags | 32));
- if ((this.m_nFlags & 8) != 0) {
- var3.width += Math.abs(this.m_cShadowOffsetX);
- var3.height += Math.abs(this.m_cShadowOffsetY);
- if ((this.m_nFlags & 2) != 0) {
- var3.x -= Math.abs(this.m_cShadowOffsetX / 2);
- } else if ((this.m_nFlags & 4) != 0) {
- var3.x -= Math.abs(this.m_cShadowOffsetX);
- }
-
- var3.x = Math.max(var3.x, ((CDisplayAction)this).GetActualRect().x);
- var3.width = Math.min(var3.width, ((CDisplayAction)this).GetActualRect().width);
- }
- }
-
- if (!((Rectangle)var3).equals(((CDisplayAction)this).GetDrawRect())) {
- if (!((CDisplayAction)this).GetDrawRect().isEmpty()) {
- Globals.thePresView.InvalidateOffScreenRect(((CDisplayAction)this).GetDrawRect());
- }
-
- ((CDisplayAction)this).SetDrawRect(var3);
- var1 = true;
- }
- }
-
- if (super.m_Effect.HasValidEffect()) {
- Globals.thePresView.RenderAndDrawDirtyList();
- Globals.thePresView.AddDrawObject((CIconObject)this, 2048, var1);
- } else {
- Globals.thePresView.AddDrawObject((CIconObject)this, 0, var1);
- }
-
- return true;
- }
-
- void DrawObject(Graphics var1, int var2, CRect var3) {
- var1.setFont(this.m_Font.GetFont());
- if ((this.m_nFlags & 16) != 0) {
- var1.setColor(this.m_rgbBackground);
- var1.fillRect(var3.x, var3.y, var3.width, var3.height);
- }
-
- if ((this.m_nFlags & 8) != 0) {
- if (this.m_cShadowOffsetX > 0) {
- var3.x += this.m_cShadowOffsetX;
- }
-
- if (this.m_cShadowOffsetY > 0) {
- var3.y += this.m_cShadowOffsetX;
- }
-
- var3.width -= Math.abs(this.m_cShadowOffsetX);
- var3.height -= Math.abs(this.m_cShadowOffsetY);
- var1.setColor(this.m_rgbShadow);
- Utils.DrawText(var1, this.m_strPaintText, var3, this.m_nFlags);
- ((Rectangle)var3).move(var3.x - this.m_cShadowOffsetX, var3.y - this.m_cShadowOffsetY);
- }
-
- var1.setColor(this.m_rgbText);
- Utils.DrawText(var1, this.m_strPaintText, var3, this.m_nFlags);
- }
-
- boolean LoadFromFile(DataInputStream var1) {
- this.m_nFlags = FileLoad.ReadCPlusInt(var1);
- this.m_rgbText = FileLoad.ReadColor(var1);
- this.m_rgbBackground = FileLoad.ReadColor(var1);
- this.m_strText = FileLoad.ReadCString(var1);
- this.m_cShadowOffsetX = (byte)FileLoad.ReadCPlusByte(var1);
- this.m_cShadowOffsetY = (byte)FileLoad.ReadCPlusByte(var1);
- this.m_rgbShadow = FileLoad.ReadColor(var1);
- this.m_vvAngle.LoadFromFile(var1);
- this.m_Font.LoadFromFile(var1);
- return super.LoadFromFile(var1);
- }
-
- public CTextAction() {
- ((CIconObject)this).SetTypeID(22);
- this.m_rgbText = new Color(0, 0, 0);
- this.m_rgbBackground = new Color(0, 0, 0);
- this.m_rgbShadow = new Color(0, 0, 0);
- this.m_Font = new CFontObject();
- this.m_vvAngle = new CVarOrValue();
- this.m_strPaintText = "";
- ((CDisplayAction)this).SetZOrder((short)4);
- }
- }
-